--
-- Author: shineflag
-- Date: 2017-07-30 11:48:42
--
--给连续的用户加金币 redis 脚本
--用法 redis-cli -h 127.0.0.1 -p 4501 --eval addcoin.lua 10001 10193 1000

local mids = {}
for mid = tonumber(KEYS[1]), tonumber(KEYS[2]) do 
	local key = string.format("ginfo_%s",mid)
	local exists = redis.call("exists",key)
	if  exists == 1 then
		local num = redis.call("hincrby",key, "money", tonumber(KEYS[3]))--tonumber(ARGV[1]) )
		local str = string.format("%d=%d",mid,num)
		table.insert(mids, str)
	end
end
return table.concat(mids," ")